package cn.vq3.kmsaiserver.kmsaiserver.utils;

import cn.vq3.kmsaiserver.kmsaiserver.pojo.sendMessageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.IOException;
import java.util.Map;

@Component
public class sendParameterAssembled {
    @Autowired
    loadProperties properties;

    public sendMessageEntity sendParameterAssembled() throws IOException {
        sendMessageEntity sendMessageEntity = new sendMessageEntity();
        File directory = new File("");
        // idea 用这个跑
        // String path = directory.getCanonicalPath()+"\\src\\main\\resources\\sendSettingData.yaml";

        // 服务器用这个跑
        String path = directory.getCanonicalPath()+"/sendSettingData.yaml";
        Map<String, Object> stringObjectMap = properties.loadProperties(path);

        if ((boolean) stringObjectMap.get("is_top_p")) {
            sendMessageEntity.setTop_p((double) stringObjectMap.get("top_p"));
        }
        if ((boolean) stringObjectMap.get("is_enable_citation")) {
            sendMessageEntity.setEnable_citation((boolean)stringObjectMap.get("enable_citation"));
        }
        if ((boolean) stringObjectMap.get("is_penalty_score")) {
            sendMessageEntity.setPenalty_score((int)stringObjectMap.get("penalty_score"));
        }
        if ((boolean) stringObjectMap.get("is_temperature")) {
            sendMessageEntity.setTemperature((double)stringObjectMap.get("temperature"));
        }
        if ((boolean) stringObjectMap.get("is_disable_search")) {
            sendMessageEntity.setDisable_search((boolean)stringObjectMap.get("disable_search"));
        }
        if ((boolean) stringObjectMap.get("is_user_id")) {
            sendMessageEntity.setUser_id((String)stringObjectMap.get("user_id"));
        }
        if ((boolean) stringObjectMap.get("is_system")) {
            sendMessageEntity.setSystem((String)stringObjectMap.get("system"));
        }
        if ((boolean) stringObjectMap.get("is_stop")) {
            sendMessageEntity.setStop((String)stringObjectMap.get("stop"));
        }
        if ((boolean) stringObjectMap.get("is_max_output_tokens")) {
            sendMessageEntity.setMax_output_tokens((String)stringObjectMap.get("max_output_tokens"));
        }
        if ((boolean) stringObjectMap.get("is_response_format")) {
            sendMessageEntity.setResponse_format((String)stringObjectMap.get("response_format"));
        }


        return sendMessageEntity;
    }
}
